package a4_queue;

import a4_queue.impl.LoopQueue;

/**
 * 测试循环队列
 */
public class TestLoopQueue {
    public static void main(String[] args) {

        LoopQueue<Integer> loopQueue = new LoopQueue<>(6);

        loopQueue.offer(1);
        loopQueue.offer(3);
        loopQueue.offer(5);
        //Front [1, 3, 5] Tail
        System.out.println(loopQueue);

        System.out.println(loopQueue.poll());
        //Front [3, 5] Tail
        System.out.println(loopQueue);
        System.out.println(loopQueue.peek());

        System.out.println("---------------------------");

        LoopQueue<String> loopQueue1 = new LoopQueue<>(5);

        loopQueue1.offer("I");
        loopQueue1.offer("am");
        loopQueue1.offer("superhero");
        //Front [I, am, superhero] Tail
        System.out.println(loopQueue1);

        System.out.println(loopQueue1.poll());
        //Front [am, superhero] Tail
        System.out.println(loopQueue1);

        System.out.println("---------------------------");

        LoopQueue<Character> loopQueue2 = new LoopQueue<>(3);
        loopQueue2.offer('a');
        loopQueue2.offer('b');
        loopQueue2.offer('c');
        //Front [a, b, c] Tail
        System.out.println(loopQueue2);
        loopQueue2.offer('d'); //已满，抛出异常
        System.out.println(loopQueue2);
    }
}
